The string is 15 characters long
An object consists of both variables (state information) and methods (small programs). Both of these are called members of the object. Java uses dot notation for both:
referenceToAnObject.memberOfObject
For example, to invoke the length()
method of the object
named str1
do this:
len = str1.length();
Method names have ()
at their end.
Often there is additional information inside the ()
,
but they are required even if they contain nothing.
The above method evaluates to an integer, 15, which is assigned to
the int
variable len
.
(Thought Question:) Is it possible for a program to have several objects all of the same class?